using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace QLNS.Data
{
    public class ThanNhan_db
    {
        Services m_Ds = new Services();
        public ThanNhan_db() { }

        public DataTable DanhSachThanNhan()
        {
            OleDbCommand cmd = new OleDbCommand("SELECT TN.ID AS ID, TN.NhanVien_ID,TN.HoTen,TN.NgaySinh,TN.DiaChi FROM THANNHAN TN, LOAIQUANHE LQH,NHANVIEN NV where TN.ID=LQH.ID and TN.NhanVien_ID=NV.ID  ");
            m_Ds.Load(cmd);

            return m_Ds;
        }

        public DataRow NewRow()
        {
            return m_Ds.NewRow();
        }

        public void Add(DataRow row)
        {
            m_Ds.Rows.Add(row);
        }

        public bool Save()
        {
            return m_Ds.ExecuteNoneQuery() > 0;
        }
        public DataTable TimTheoTen(string ten)
        {
            string sql = "SELECT * FROM THANNHAN where HoTen like '%" + ten + "%'";
            OleDbCommand cmd = new OleDbCommand(sql);
            m_Ds.Load(cmd);

            return m_Ds;
        }

        public DataTable TimTheoMa(string id)
        {
            string sql = "SELECT * FROM THANNHAN where ID like '%" + id + "%'";
            OleDbCommand cmd = new OleDbCommand(sql);
            m_Ds.Load(cmd);

            return m_Ds;
        }
    }
}
